package com.liaoban.app.ui.home;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.view.View;
import android.widget.ImageView;

import com.liaoban.app.R;
import com.liaoban.app.api.type.RecommendName;
import com.liaoban.app.biz.CommonBiz;
import com.liaoban.app.ui.base.BaseTabHostActivity;
import com.liaoban.app.ui.rank.RankChildFragment;
import com.liaoban.app.ui.rank.SearchActivity;
import com.liaoban.app.util.CommonUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by ybc on 2018/7/13 0013.
 * 聊伴主播秀
 */
public class AnchorActivity extends BaseTabHostActivity {
    @BindView(R.id.iv_right)
    ImageView ivRight;

    private Class[] classes;
    private String[] strings;
    private Bundle[] bundles;

    @Override
    protected String getNewTitle() {
        return "聊伴主播秀";
    }

    @Override
    protected String[] getTitleList() {
        return strings;
    }

    @Override
    protected Class[] getFragmentList() {
        return classes;
    }

    @Override
    protected Bundle[] getBundles() {
        return bundles;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        showRunningDialog();
        startTask(CommonBiz.getInstance().wuserListName(), listBaseResponse -> {
            List<RecommendName> recommendNames = listBaseResponse.data;
            if(CommonUtils.isEmpty(recommendNames)) {
                return;
            }
            int size = recommendNames.size();
            classes = new Class[size];
            strings = new String[size];
            bundles = new Bundle[size];
            for(int i = 0; i < size; i++) {
                RecommendName recommendName = recommendNames.get(i);
                classes[i] = AnchorFragment.class;
                strings[i] = recommendName.getFormContent();
                bundles[i] = AnchorFragment.getBundle(recommendName.getFormId());
            }
            super.initView(savedInstanceState);
            ivRight.setImageResource(R.mipmap.ic_search_title);
            ivRight.setVisibility(View.VISIBLE);
            mainTab.setTabMode(TabLayout.LAYOUT_MODE_CLIP_BOUNDS);
            CommonUtils.setTabLayoutWidth(mainTab, 14);
        });
    }

    @OnClick(R.id.iv_right)
    public void right() {
        startActivity(new Intent(this, SearchActivity.class));
    }

}
